
type cbProgress = ((completedCount: number, totalCount: number, item: any) => void);
type cbComplete = ((error: Error, resource: any) => void);  
   
export default class api_explorer {
    private static map:Map<string,any> = new Map();
    //加载本地资源
    public static locaLoading(url:string,type:typeof cc.Asset,cbProgress:cbProgress,cbComplete:cbComplete):void{
        let map = api_explorer.map;
        let src = map[url];
        if(!src){
            cc.loader.loadRes(url,type,cbProgress,cbComplete);
        }
        else{
            setTimeout(function(){
                cbComplete(null,src);
            }.bind(this));
        }
    }

    //加载远程资源
    public static remotLoading(url:string,type:string,cbComplete?: Function){
        let map = api_explorer.map;
        let src = map[url];
        if(!src){
            cc.loader.load({url:url, type:type},cbComplete);
        }
        else{
            setTimeout(function(){
                cbComplete(null,src);
            }.bind(this));
        }
    }

    //加载远程资源
    public static remotLoadings(urls:string[],cbComplete?: Function){
        cc.loader.load(urls,cbComplete);
    }

    //加载远程png
    public static pngRemote(url:string,cbComplete?: Function){
        this.remotLoading(url,"png",cbComplete)
    }

    //加载远程jep
    public static jpgRemote(url:string,cbComplete?: Function){
        this.remotLoading(url,"jpg",cbComplete)
    }

    //加载远程jep
    public static imageRemote(url:string,cbComplete?: Function){
        this.remotLoading(url,null,cbComplete)
    }

    //加载远程jep
    public static imageRemotes(url:string[],cbComplete?: Function){
        this.remotLoadings(url,cbComplete)
    }
}